﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASCalpuff.FileLayers
{

    /// <summary>
    /// 气象数据选项
    /// </summary>
    public class MG4 : Group
    {
        private int m_NOOBS = 0;


        /// <summary>
        ///降雨站个数
        /// </summary>
        private int m_NPSTA = 0;
        /// <summary>
        ///  地面站和降雨站站点数
        /// </summary>
        private int m_NSSTA = 1;

        /// <summary>
        /// 云数据来源
        /// = 0 -不适用网格云场 
        /// = 1 - Gridded CLOUD.DAT generated as OUTPUT
        /// = 2 - Gridded CLOUD.DAT read as INPUT
        /// = 3 – 网格云场数据来自850mb的诊断的湿度
        /// = 4 -网格云场数据来自所有层的诊断的湿度
        /// </summary>

        private int m_ICLOUD = 0;
        //数据格式FILE FORMATS

        /// <summary>
        /// 地面气象数据格式
        /// 1 = unformatted (e.g., SMERGE output))
        /// 2 = formatted   (free-formatted user input))
        /// </summary>
        private int m_IFORMS = 2;



        /// <summary>
        ///降雨数据格式
        /// 1 = unformatted (e.g., SMERGE output))
        /// 2 = formatted   (free-formatted user input))
        /// </summary>
        private int m_IFORMP = 2;

        /// <summary>
        ///云量数据格式
        /// 1 = unformatted (e.g., SMERGE output))
        /// 2 = formatted   (free-formatted user input))
        /// </summary>
        private int m_IFORMC = 2;



        #region 对应的属性

        // Properties
        public int ICLOUD
        {
            get
            {
                return this.m_ICLOUD;
            }
            set
            {
                this.m_ICLOUD = value;
            }
        }

        public int IFORMC
        {
            get
            {
                return this.m_IFORMC;
            }
            set
            {
                this.m_IFORMC = value;
            }
        }

        public int IFORMP
        {
            get
            {
                return this.m_IFORMP;
            }
            set
            {
                this.m_IFORMP = value;
            }
        }

        public int IFORMS
        {
            get
            {
                return this.m_IFORMS;
            }
            set
            {
                this.m_IFORMS = value;
            }
        }

        public int NOOBS
        {
            get
            {
                return this.m_NOOBS;
            }
            set
            {
                this.m_NOOBS = value;
            }
        }

        public int NPSTA
        {
            get
            {
                return this.m_NPSTA;
            }
            set
            {
                this.m_NPSTA = value;
            }
        }

        public int NSSTA
        {
            get
            {
                return this.m_NSSTA;
            }
            set
            {
                this.m_NSSTA = value;
            }
        }


        #endregion

        public override string WriteToGroup()
        {
            string Str = "-------------------------------------------------------------------------------\r\nINPUT GROUP: 4 -- Meteorological data options\r\n-------------------------------------------------------------------------------\r\n";
            string mEnd = "   !";
            string ResultStr = (Str + "! NOOBS =  " + this.NOOBS.ToString() + mEnd + "\r\n! NSSTA =  " + this.NSSTA.ToString() + mEnd + "\r\n! NPSTA =  " + this.NPSTA.ToString() + mEnd + "\r\n! ICLOUD =  " + this.ICLOUD.ToString() + mEnd + "\r\n! IFORMS =  " + this.IFORMS.ToString() + mEnd + "\r\n! IFORMP =  " + this.IFORMP.ToString() + mEnd + "\r\n! IFORMC =  " + this.IFORMC.ToString() + mEnd + "\r\n!END!\r\n");
            string TempStr = StrWriter.GetCLine();
            ResultStr += TempStr;
            return ResultStr;

        }
        public override void ReadFromGroup(Dictionary<string, string> dic)
        {
            foreach (KeyValuePair<string, string> m_dic in dic)
            {
                if (m_dic.Key == "ICLOUD")
                {
                    this.ICLOUD = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "IFORMC")
                {
                    this.IFORMC = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "IFORMP")
                {
                    this.IFORMP = Convert.ToInt32(m_dic.Value);
                }

                if (m_dic.Key == "IFORMS")
                {
                    this.IFORMS = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "NOOBS")
                {
                    this.NOOBS = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "NPSTA")
                {
                    this.NPSTA = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "NSSTA")
                {
                    this.NSSTA = Convert.ToInt32(m_dic.Value);
                }
            }
        }
    }
}
